<!DOCTYPE html>
<html>
<head>
	<title>会员登录</title>
	<meta name="keywords" content="" />
	<meta name="description" content=""/>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
	<link rel="stylesheet" href="__TMPL__/public/user/css/login_base.css">
	<link rel="stylesheet" href="__TMPL__/public/user/css/login_wap.css">
	<script src="__TMPL__/public/assets/js/jquery.min.js"></script>
  <style>
  input {-webkit-appearance:none; /*去除input默认样式*/}
  </style>
	<script type="text/javascript" src="__TMPL__/public/assets/js/layer/layer.js"></script>
</head>
<body  style="background:#f1f1f1">
<div class="content">



	<section class="head" style="background:#fff">
		<a  onclick="window.history.go(-1)" href="javascript:void(0)" style="background: url(__TMPL__/public/assets/img/back.png) no-repeat right;background-position-x: 17px;background-size: 13px;display: block;height: 44px;line-height: 44px;flex: 3;width: 50px;float: left;"></a>
		<div class="head-title">会员登录</div>
	</section> 
	


	<div class="log-wp">
		<div class="log-box">

			<div>
				<div class="nk-cont">
					<label> <img src="__TMPL__/public/user/image/shouji.png" style="width: 13px;margin: 11px;float:  left;"><input type="text" id="mobile"
															  name="mobile" placeholder="请输入手机号码">
					</label>
				</div>
				<div class="nk-cont">
					<label> <img src="__TMPL__/public/user/image/yanzm.png" style="width: 13px;margin: 11px;float:  left;"><input class="" type="text" id="captcha" name="captcha" placeholder="请输入验证码 ">
						<div class="verify">  <captcha height="40" width="95" font-size="14" useCurve="false" useNoise="false" codeSet="0123456789" style="cursor: pointer;" /></div>
					</label>
				</div>
				<div class="nk-cont" style="background: #f1f1f1;">
					<label>
           <span style="background:  #fff;float: left;border-radius:  6px;width: 60%;"><img src="__TMPL__/public/user/image/mima.png" style="width: 13px;margin: 11px;float:  left;"><input type="text"	 id="sms_captcha" name="sms_captcha" placeholder="请输入动态码"></span>
						<input type="button" id="sendOutCode" onclick="sendOutCode()" value="获取动态码">
					</label>
				</div>
				<input type="hidden" id="mobile_is_has" value="1">
				<button id="login-button" class="lang-btn" onclick="check_mobile()">登录</button>

			</div>

			<div class="nk_regist" style="color: #DDC38A;">
				未注册手机,验证后自动注册登录
			</div>


		</div>
	</div>


	<!-- 结束 -->

	<script type="text/javascript">

        //发送验证码
        function sendOutCode(){
            var mobile = $("#mobile").val();
            var vertification = $("#captcha").val();
            //验证手机号格式是否正确
            if(mobile.search(/^1(3|4|5|7|8)\d{9}$/) == -1){
                $("#mobile").trigger("focus");
                layer.msg("请输入正确的手机格式");
                return false;
            }
            if(vertification == ''){
                $("#captcha").trigger("focus");
                layer.msg("请输入验证码 ");
                return false;
            }
            //验证手机号是否已经注册
            $.ajax({
                type: "POST",
                url: "{:url('user/VerificationCode/send')}",
                data: {"username":mobile,"captcha":vertification},
                success: function(data){
                    layer.msg(data.msg);
                    if(data['code']==1){
                        time();
                    }else{
                        $('.captcha-img').click();
                    }
                }
            });
        }
        var wait=120;
        function time() {
            if (wait == 0) {
                $("#sendOutCode").removeAttr("disabled");
                $("#sendOutCode").css("background-color", "#23262f");
                $("#sendOutCode").css("color", "#ffffff");
                $("#sendOutCode").val("获取验证码");
                wait = 120;
            } else {
                $("#sendOutCode").attr("disabled", 'disabled');
                $("#sendOutCode").css("background-color", "#949494");
                $("#sendOutCode").css("color", "#ccc");
                $("#sendOutCode").val(wait+"s后重新发送");
                wait--;
                setTimeout(function() {
                        time()
                    },
                    1000)
            }
        }
        function check_mobile(){
            var mobile = $("#mobile").val();
            var captcha = $("#captcha").val();
            var sms_captcha = $("#sms_captcha").val();
            var mobile_is_has = $("#mobile_is_has").val();
            if(mobile == ''){
                $("#mobile").trigger("focus");
                layer.msg("手机号不能为空");
                return false;
            }else if(mobile.search(/^1(3|4|5|7|8)\d{9}$/) == -1){
                $("#mobile").trigger("focus");
                layer.msg("请输入正确的手机格式");
                return false;
            }else if(mobile_is_has == 0){
                layer.msg("当前手机号还未注册");
                return false;
            }else if(captcha == ''){
                layer.msg("验证码不能为空");
                return false;
            }else if(sms_captcha == ''){
                layer.msg("动态码不能为空");
                return false;
            }
            $.ajax({
                type : "post",
                url : "{:url('user/login/ajax_do_login')}",
                async : true,
                data : {
                    "username" : mobile,
                    "code" : sms_captcha
                },
                success : function(data) {
                    layer.msg(data.msg);

                    if(data["code"]==1 ){
                        var usercenter="{:url('user/profile/center')}";
                        setTimeout(function(){location.href =usercenter },1000);
                    }
                }
            });
        }
	</script>
</body>
</html>